<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>订单管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/X-admin/css/font.css">
    <link rel="stylesheet" href="/X-admin/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="/X-admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/X-admin/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        订单管理
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace('{:url('Admin/PayeeOrder/index')}');" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" action="{:url('Admin/PayeeOrder/index')}">
          <input class="layui-input" placeholder="开始日" value="{notempty name="$filter.start_time"}{$filter.start_time}{/notempty}" name="start_time" id="start">
          <input class="layui-input" placeholder="截止日" value="{notempty name="$filter.end_time"}{$filter.end_time}{/notempty}" name="end_time" id="end">
          <input type="text" name="userName" value="{notempty name="$filter.userName"}{$filter.userName}{/notempty}" placeholder="用户名" autocomplete="off" class="layui-input">
          <input type="text" name="shopName" value="{notempty name="$filter.shopName"}{$filter.shopName}{/notempty}" placeholder="商店名" autocomplete="off" class="layui-input">
          <input type="text" name="orderNumber" value="{notempty name="$filter.orderNumber"}{$filter.orderNumber}{/notempty}" placeholder="订单号" autocomplete="off" class="layui-input">
          <input type="text" name="wxOrder" value="{notempty name="$filter.wxOrder"}{$filter.wxOrder}{/notempty}" placeholder="三方订单号" autocomplete="off" class="layui-input">

          <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
      </div>
      <xblock>
<!--         <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
        <button class="layui-btn" onclick="x_admin_show('添加商铺','{:url('Admin/PayeeOrder/add')}')"><i class="layui-icon"></i>添加</button> -->
        <span class="x-right" style="line-height:40px">共有数据：{:$arr->total()} 条</span>
      </xblock>
      <table class="layui-table">
        <thead>
          <tr>
            <th>订单号</th>
            <th>三方订单号</th>            
            <th>用户</th>    
      			<th>员工</th>
            <th>商店</th>
            <th>商品</th>
            <th>金额(原价)</th>
            <th>vip价格</th>
            <th>实际支付</th>
            <th>补贴金额</th>
            <th>打赏</th>
            <th>商店收入</th>
            <th>支付方式</th>
            <th>支付状态</th>
            <th>支付时间</th>
            <th>操作</th>
<!--               `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `orderNumber` char(50) DEFAULT NULL COMMENT '订单号',
  `wxOrder` char(50) DEFAULT NULL COMMENT '三方订单号',
  `userId` bigint(20) DEFAULT NULL COMMENT '用户id(陌客就没有)',
  `userStatus` int(1) DEFAULT NULL COMMENT '用户状态,1非vip(陌客),2vip',
  `staffId` bigint(20) DEFAULT NULL COMMENT '员工表id',
  `shopId` bigint(20) DEFAULT NULL COMMENT '商户表Id',
  `commodityId` char(100) DEFAULT NULL COMMENT '商品ID 如有多个以逗号分割：1,2,3',
  `commodityPrice` text COMMENT '商品价格,如有多个,用逗号隔开:10.00,82.00',
  `amount` decimal(10,2) DEFAULT NULL COMMENT '金额(原价)',
  `vipAmount` decimal(10,2) DEFAULT NULL COMMENT 'vip价格',
  `discountMoney` decimal(10,2) DEFAULT NULL COMMENT '实际支付金额',
  `subsidy` decimal(10,2) DEFAULT NULL COMMENT '补贴金额',
  `reward` decimal(10,2) DEFAULT NULL COMMENT '打赏',
  `paymentWay` int(1) DEFAULT NULL COMMENT '支付方式,1微信支付,2现金支付',
  `shopIncome` decimal(10,2) DEFAULT NULL COMMENT '店铺收入',
  `systemIncome` decimal(10,2) DEFAULT NULL COMMENT '平台收入',
  `type` int(1) DEFAULT NULL COMMENT '上门状态，1：上门，2：到店 , 3: 陌客 ',
  `status` int(1) unsigned zerofill DEFAULT '0' COMMENT '订单状态 0:无状态 1：预约，2：开始服务，3：已完成 ,4退款中,5已退款,6,用户取消(门店)',
  `paytime` datetime DEFAULT NULL COMMENT '支付时间',
  `refundtime` datetime DEFAULT NULL COMMENT '退款时间',
  `appRefundtime` datetime DEFAULT NULL COMMENT '申请退款时间',
  `addtime` datetime DEFAULT NULL COMMENT '创建时间',
  `updtime` datetime DEFAULT NULL COMMENT '修改时间',
  `payStatus` int(1) DEFAULT NULL COMMENT '支付状态1未支付,2已支付',
  `orderNo` int(11) DEFAULT NULL COMMENT '预约号',
  `appointId` bigint(20) DEFAULT NULL COMMENT '预约id',
  `overTime` datetime DEFAULT NULL COMMENT '订单到期时间(到店订单才会有)', -->
        </thead>
        <tbody>{foreach name="items" item="vo"}		
          <tr>
            <td>{$vo.orderNumber}</td>
            <td>{$vo.wxOrder}</td>
            <td>{$vo.userName}</td>
      			<td>{$vo.staffName}</td>
            <th>{$vo.shopName}</th>
            <td>
            {foreach name="vo.commodityId" item="li"}  
              {$li.name}<br/>
            {/foreach}
            </td>
            <td>{$vo.amount}</td>
            <td>{$vo.vipAmount}</td>
            <td>{$vo.discountMoney}</td>
            <td>{$vo.subsidy}</td>
            <td>{$vo.reward}</td>
            <td>{$vo.shopIncome}</td>
            <td>{$vo.paymentWay==1? '微信' : '现金'}</td>
            <td>{$vo.payStatus==1? '未支付' : '已支付'}</td>
            <td>{$vo.paytime}</td>
            <td class="td-manage">
            {if condition="$vo.status eq 1"}
              <a title="完成"  onclick="member_status(this,'{$vo.id}',1)" href="javascript:;">
                <i class="layui-icon">&#xe605;</i>
              </a> 
            {/if}
            {if condition="($vo.payStatus eq 2)and($vo.status neq 5)"}
              <a title="退单" onclick="member_status(this,'{$vo.id}',2)" href="javascript:;">
                <i class="layui-icon">&#x1006;</i>
              </a>
            {/if}
            </td>
          </tr>{/foreach}
        </tbody>
      </table>
      <div class="page">
          {$arr->render()}
      <div>

		<!--
          <a class="prev" href="">&lt;&lt;</a>
          <a class="num" href="">1</a>
          <span class="current">2</span>
          <a class="num" href="">3</a>
          <a class="num" href="">489</a>
          <a class="next" href="">&gt;&gt;</a>-->
        </div>
      </div>

    </div>
    <script>
      layui.use('laydate', function(){
        var laydate = layui.laydate;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });

       /*用户-停用*/
      function member_stop(obj,id){
          layer.confirm('确认改变状态吗？',function(index){ 
              if($(obj).attr('title')=='启用'){

                //发异步把用户状态进行更改
			  jQuery.ajax({  
				url: "{:url('Admin/PayeeOrder/changeState')}",  
				type: "post",  
				dataType: "json",  
				async: true,  
				data: {
				id   : id,
				state: 0
				},  
				success: function(data){  
					if(data.code){					
					    $(obj).attr('title','停用')
						$(obj).find('i').html('&#xe62f;');

						$(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
						layer.msg('已停用!',{icon: 5,time:1000});
					
					
					}else{
						layer.msg('管理员状态改变失败!!',{icon: 5,time:1000});
					}
					
				},
				error: function (XMLHttpRequest, textStatus, errorThrown) {	
						layer.msg('执行时发生一个未知错误！错误代码：'+textStatus,{icon: 5,time:3000});
				}			
			});				


              }else{
			  
			  
			  
                //发异步把用户状态进行更改
			  jQuery.ajax({  
				url: "{:url('Admin/PayeeOrder/changeState')}",  
				type: "post",  
				dataType: "json",  
				async: true,  
				data: {
				id   : id,
				state: 1
				},  
				success: function(data){  
					if(data.code){	
					
						$(obj).attr('title','启用')
						$(obj).find('i').html('&#xe601;');

						$(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
						layer.msg('已启用!',{icon: 5,time:1000});					
					
					}else{
						//$(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
						layer.msg('管理员状态改变失败!!',{icon: 5,time:1000});
					}
					
				},
				error: function (XMLHttpRequest, textStatus, errorThrown) {	
						layer.msg('执行时发生一个未知错误！错误代码：'+textStatus,{icon: 5,time:3000});
				}				
			});				  
			  
			  
			  
              }
              
          });
      }

      /*用户-删除*/
      function member_del(obj,id){
          layer.confirm('确认要删除吗？',function(index){
              //发异步删除数据
			  jQuery.ajax({  
				url: "{:url('Admin/PayeeOrder/del')}",  
				type: "post",  
				dataType: "json",  
				async: true,  
				data: {
				id: id
				},  
				success: function(data){  
					if(data.code){
						$(obj).parents("tr").remove();
						layer.msg(data.msg,{icon:1,time:1000});
					}else{
						layer.msg(data.msg,{icon:1,time:1000})
					}
					
				} ,
				error: function (XMLHttpRequest, textStatus, errorThrown) {	
						layer.msg('执行时发生一个未知错误！错误代码：'+textStatus,{icon: 5,time:3000});
				}				
			}); 
              //
          });
      }
      /*修改状态*/
      function member_status(obj,id,status){
          layer.confirm('确认要修改订单状态吗？',function(index){
              //发异步删除数据
                jQuery.ajax({  
                url: "{:url('Admin/PayeeOrder/statusPay')}",  
                type: "post",  
                dataType: "json",  
                async: true,  
                data: {
                id: id,
                status:status
                },  
                success: function(data){  
                  if(data.code==200){
                    //$(obj).parents("tr").reload();
                    layer.msg(data.msg,{icon:1,time:1000},function(){
                                    location.reload(); // 父页面刷新
                                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                    parent.layer.close(index);
                    });
                  }else{
                    layer.msg(data.msg,{icon:1,time:1000})
                  }
                  
                } ,
           
              }); 
            //
          });
      }


      function delAll (argument) {

        var data = tableCheck.getData();
  
        layer.confirm('确认要删除吗？'+data,function(index){

			  jQuery.ajax({  
				url: "{:url('Admin/PayeeOrder/delAll')}",  
				type: "post",  
				dataType: "json",  
				async: true, 			
				data: {
				ids:data
				},  
				success: function(data){  
					if(data.code){
						layer.msg(data.msg, {icon: 1});
						$(".layui-form-checked").not('.header').parents('tr').remove();
					}else{
						layer.msg(data.msg, {icon: 1});
						$(".layui-form-checked").not('.header').parents('tr').remove();
					}
					
				} ,
				error: function (XMLHttpRequest, textStatus, errorThrown) {	
						layer.msg('执行时发生一个未知错误！错误代码：'+textStatus,{icon: 5,time:3000});
				}				
			});		
		
            
        });
      }
    </script>
  </body>

</html>